package cn.maihe.elg.operation.repository.entity;

import cn.maihe.elg.operation.repository.entity.OrganizationVo;
import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_organization")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.OrganizationMapper")
public class OrganizationDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 上级机构ID
     */
    @TableField(value = "parent_id")
    private Long parentId;

    /**
     * 机构全称
     */
    @TableField(value = "full_name")
    private String fullName;

    /**
     * 机构简称
     */
    @TableField(value = "simple_name")
    private String simpleName;

    /**
     * 机构代码
     */
    @TableField(value = "org_code")
    private String orgCode;

    /**
     * 企业类型：0-股份有限公司 1-责任有限公司 2-中外合资 3-外商融资 4-股份合作 5-集体 6-合伙 7-其他
     */
    @TableField(value = "company_type")
    private Integer companyType;

    /**
     * 行业类型：01-银行 02-担保公司 03-担保联合体 04-保险公司 05-保险公司代理 11-承建单位/承包商/供应商 12-建设单位/业务/开发商 13-交易中心 14-招标代理 15-交易中心服务商
     */
    @TableField(value = "industry_type")
    private String industryType;

    /**
     * 业务联系人姓名
     */
    @TableField(value = "contact_name")
    private String contactName;

    /**
     * 业务联系人电话
     */
    @TableField(value = "contact_tel")
    private String contactTel;

    /**
     * 业务联系人邮箱
     */
    @TableField(value = "contact_email")
    private String contactEmail;

    @TableField(value = "contact_addr")
    private String contactAddr;

    /**
     * 统一社会信用代码
     */
    @TableField(value = "credit_code")
    private String creditCode;

    /**
     * 开户行行号
     */
    @TableField(value = "open_bank_no")
    private String openBankNo;

    /**
     * 开户行名称
     */
    @TableField(value = "open_bank_name")
    private String openBankName;

    /**
     * 基本账户账号
     */
    @TableField(value = "bank_account")
    private String bankAccount;

    /**
     * 开户许可证号
     */
    @TableField(value = "account_open_license_no")
    private String accountOpenLicenseNo;

    /**
     * 注册资本（元）
     */
    @TableField(value = "registered_capital")
    private String registeredCapital;

    /**
     * 法人姓名
     */
    @TableField(value = "legal_name")
    private String legalName;

    /**
     * 法人身份证号
     */
    @TableField(value = "legal_idcard")
    private String legalIdcard;

    /**
     * 法人手机号码
     */
    @TableField(value = "legal_mobile")
    private String legalMobile;

    /**
     * 法人身份证生效开始日期
     */
    @TableField(value = "idcard_start_date")
    private String idcardStartDate;

    /**
     * 法人身份证生效截止日期
     */
    @TableField(value = "idcard_end_date")
    private String idcardEndDate;

    /**
     * 营业执照号码
     */
    @TableField(value = "business_license")
    private String businessLicense;

    /**
     * 营业执照生效开始日期
     */
    @TableField(value = "setup_start_date")
    private String setupStartDate;

    /**
     * 营业执照生效截止日期
     */
    @TableField(value = "setup_end_date")
    private String setupEndDate;

    /**
     * 注册地址
     */
    @TableField(value = "address")
    private String address;

    /**
     * 所属省份代码
     */
    @TableField(value = "province_code")
    private String provinceCode;

    /**
     * 所属城市代码
     */
    @TableField(value = "city_code")
    private String cityCode;

    /**
     * 所属县区代码
     */
    @TableField(value = "county_code")
    private String countyCode;

    /**
     * 法人身份证反面照片
     */
    @TableField(value = "legal_idcard_reverse_pic")
    private String legalIdcardReversePic;

    /**
     * 法人身份证正反面照片
     */
    @TableField(value = "legal_idcard_pic")
    private String legalIdcardPic;

    /**
     * 营业执照加盖公章照片
     */
    @TableField(value = "business_license_pic")
    private String businessLicensePic;

    /**
     * 开展业务启用状态 0已关闭 1已开启 (仅有资质材料审核后)
     */
    @TableField(value = "business_status")
    private Integer businessStatus;

    /**
     * 审核状态（0未审核 1已审核 2待审核 3审核拒绝）
     */
    @TableField(value = "audit_status")
    private Integer auditStatus;

    /**
     * 组织机构代码证照片
     */
    @TableField(value = "org_code_cert_pic")
    private String orgCodeCertPic;

    /**
     * 税务登记证照片
     */
    @TableField(value = "tax_reg_cert_pic")
    private String taxRegCertPic;

    /**
     * 开户许可证照片
     */
    @TableField(value = "account_open_license_pic")
    private String accountOpenLicensePic;

    /**
     * 删除标记
     */
    @TableField(value = "del_flag")
    private String delFlag;

    /**
     * 技术联系人姓名
     */
    @TableField(value = "technology_contact_name")
    private String technologyContactName;

    /**
     * 技术联系人电话
     */
    @TableField(value = "technology_contact_tel")
    private String technologyContactTel;

    /**
     * 技术联系人邮箱
     */
    @TableField(value = "technology_contact_email")
    private String technologyContactEmail;

    /**
     * 技术联系人地址
     */
    @TableField(value = "technology_contact_addr")
    private String technologyContactAddr;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 机构入驻自动创建机构用户id
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 审核结果描述
     */
    @TableField(value = "audit_desc")
    private String auditDesc;

    /**
     * 创建渠道企业返回的企业Id
     */
    @TableField(value = "enterprise_id")
    private Long enterpriseId;

    /**
     * 渠道创建结果查询次数
     */
    @TableField(value = "result_query_times")
    private Integer resultQueryTimes;

    /**
     * 申请书
     */
    @TableField(value = "apply_pic")
    private String applyPic;

    /**
     * 合同公章
     */
    @TableField(value = "contact_pic")
    private String contactPic;

    /**
     * 授权书
     */
    @TableField(value = "auth_pic")
    private String authPic;

    /**
     * 联系人身份证号
     */
    @TableField(value = "contact_id_card")
    private String contactIdCard;

    public OrganizationVo buildVo() {
        return new OrganizationVo(id, parentId, fullName, simpleName, orgCode, companyType, industryType, contactName, contactTel, contactEmail, contactAddr, creditCode, openBankNo, openBankName, bankAccount, accountOpenLicenseNo, registeredCapital, legalName, legalIdcard, legalMobile, idcardStartDate, idcardEndDate, businessLicense, setupStartDate, setupEndDate, address, provinceCode, cityCode, countyCode, legalIdcardReversePic, legalIdcardPic, businessLicensePic, businessStatus, auditStatus, orgCodeCertPic, taxRegCertPic, accountOpenLicensePic, delFlag, technologyContactName, technologyContactTel, technologyContactEmail, technologyContactAddr, gmtCreate, gmtModified, userCreate, userModified, userId, auditDesc, enterpriseId, resultQueryTimes, applyPic, contactPic, authPic, contactIdCard);
    }

    public static OrganizationDO of(OrganizationVo vo) {
        return new OrganizationDO(vo.getId(), vo.getParentId(), vo.getFullName(), vo.getSimpleName(), vo.getOrgCode(), vo.getCompanyType(), vo.getIndustryType(), vo.getContactName(), vo.getContactTel(), vo.getContactEmail(), vo.getContactAddr(), vo.getCreditCode(), vo.getOpenBankNo(), vo.getOpenBankName(), vo.getBankAccount(), vo.getAccountOpenLicenseNo(), vo.getRegisteredCapital(), vo.getLegalName(), vo.getLegalIdcard(), vo.getLegalMobile(), vo.getIdcardStartDate(), vo.getIdcardEndDate(), vo.getBusinessLicense(), vo.getSetupStartDate(), vo.getSetupEndDate(), vo.getAddress(), vo.getProvinceCode(), vo.getCityCode(), vo.getCountyCode(), vo.getLegalIdcardReversePic(), vo.getLegalIdcardPic(), vo.getBusinessLicensePic(), vo.getBusinessStatus(), vo.getAuditStatus(), vo.getOrgCodeCertPic(), vo.getTaxRegCertPic(), vo.getAccountOpenLicensePic(), vo.getDelFlag(), vo.getTechnologyContactName(), vo.getTechnologyContactTel(), vo.getTechnologyContactEmail(), vo.getTechnologyContactAddr(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getUserId(), vo.getAuditDesc(), vo.getEnterpriseId(), vo.getResultQueryTimes(), vo.getApplyPic(), vo.getContactPic(), vo.getAuthPic(), vo.getContactIdCard());
    }
}